package ar.com.aterrizar.ui;

import org.uqbar.arena.actions.MessageSend;
import org.uqbar.arena.layout.HorizontalLayout;
import org.uqbar.arena.layout.VerticalLayout;
import org.uqbar.arena.widgets.Button;
import org.uqbar.arena.widgets.Label;
import org.uqbar.arena.widgets.Panel;
import org.uqbar.arena.windows.Window;
import org.uqbar.arena.windows.WindowOwner;
import ar.com.aterrizar.entidades.Cliente;
import ar.com.aterrizar.uimodels.ComprasModel;
import ar.com.aterrizar.uimodels.OperationModel;
import ar.com.aterrizar.uimodels.ReservasModel;

public class OperationWindow extends Window<OperationModel> {
	public OperationWindow(WindowOwner parent, Cliente cliente){
		super(parent, new OperationModel(cliente));
	}

	@Override
	public void createContents(Panel mainPanel) {
		this.setTitle("Aterrizar.com.ar");
		
		mainPanel.setLayout(new VerticalLayout());
		
		new Label(mainPanel).bindValueToProperty("title");
		new Label(mainPanel).setText("¿Qué desea hacer?");	
		
		Panel actionsPanel = new Panel(mainPanel).setLayout(new HorizontalLayout());

		new Button(actionsPanel)
			.setCaption("Ver Compras")
			.onClick(new MessageSend(this, "verCompras"));

		new Button(actionsPanel)
			.setCaption("Ver Reservas")
			.onClick(new MessageSend(this, "verReservas"));
	
		new Button(actionsPanel)
			.setCaption("Buscar Asientos")
			.onClick(new MessageSend(this, "verAsientos"));
	}


	public void verCompras(){
		new TransaccionesWindow(getOwner(), new ComprasModel(this.getModelObject().getCliente())).open();
	}

	public void verReservas(){
		new TransaccionesWindow(getOwner(), new ReservasModel(this.getModelObject().getCliente())).open();
	}
	
	public void verAsientos(){
		new BuscadorWindow(getOwner(), this.getModelObject().getCliente()).open();
	}


}
